package com.qf.shiro.util;


import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidDataSourceFactory;
import org.apache.commons.dbutils.QueryRunner;

import java.util.Properties;

public class DbUtils {
    private static DruidDataSource dataSource;
    private static QueryRunner qr = null;
    static{

        try {
            //需要使用工厂方式创建连接池
            Properties prop=new Properties();
            prop.load(DbUtils.class.getClassLoader().getResourceAsStream("dbDruid.properties"));
            dataSource= (DruidDataSource) DruidDataSourceFactory.createDataSource(prop);
            qr = new QueryRunner(dataSource);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static  DruidDataSource getDataSource(){
        return dataSource;
    }
    public static QueryRunner getQr(){
        return qr;
    }
}
